print('1.创建字典')
score = {'张三':100, '李四': 70, '王五': 90}
print(score)
#第二种创建方式
student = dict(name = 'jack', Sex = '男', age = 20)
print(student)
print()

print('2.字典元素的获取')
score = {'张三':100, '李四': 70, '王五': 90}
print(score['张三'])
print(score.get('张三'))
print(score.get('王柳'))
del score["张三"]
print(score)
score.clear()
print(score)
score['陈留'] = 80
print(score)
print()

print('3.获取字典视图')
score = {'张三':100, '李四': 70, '王五': 90}
keys = score.keys()
print(keys)
values = score.values()
print(values)

#获取所有的key->value键值对
items = score.items()
print(items)
print(list(items))
print()

print("4.字典生成式")
#内置函数zip()
items = ['张三', '李四', '王五']
ages = [70, 80, 90]
d={item:ages for item,ages in zip(items,ages)}
print(d)